package com.gengzp.system.controller;

import com.gengzp.common.annotations.OperationLogIgnore;
import com.gengzp.common.model.generic.resp.Result;
import com.gengzp.common.model.log.resp.SearchOperationLogCountResp;
import com.gengzp.common.model.permission.resp.SearchPermissionCountResp;
import com.gengzp.common.model.serviceGovernance.resp.SearchServiceGovernanceCountResp;
import com.gengzp.common.model.user.resp.SearchSysUserCountResp;
import com.gengzp.permission.annotation.AuthIgnore;
import com.gengzp.system.service.DashboardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName DashboardController
 * @Description 仪表板数据统计模块
 * @Author gengzp
 * @Date 2025/10/23 20:45
 */
@RestController
@RequestMapping("/dashboard")
@Api(tags = "仪表板数据统计模块")
public class DashboardController {

    @Autowired
    private DashboardService dashboardService;

    /**
     * 查询用户计数统计信息
     */
    @AuthIgnore
    @OperationLogIgnore
    @PostMapping("/user/search_count")
    @ApiOperation(value = "查询用户计数统计信息")
    public Result<SearchSysUserCountResp> searchSysUserCount() {
        return Result.getSuccessResult(dashboardService.searchSysUserCount());
    }

    /**
     * 查询系统当前接口权限统计
     */
    @AuthIgnore
    @OperationLogIgnore
    @PostMapping("/permission/search_count")
    @ApiOperation(value = "查询系统当前接口权限统计")
    public Result<SearchPermissionCountResp> searchPermissionCount() {
        return Result.getSuccessResult(dashboardService.searchPermissionCount());
    }

    /**
     * 查询系统接口调用计数信息
     */
    @AuthIgnore
    @OperationLogIgnore
    @PostMapping("/api/search_count")
    @ApiOperation(value = "查询系统接口调用计数信息")
    public Result<SearchOperationLogCountResp> searchOperationLogCount() {
        return Result.getSuccessResult(dashboardService.searchOperationLogCount());
    }

    /**
     * 查询后端服务实例统计信息
     */
    @AuthIgnore
    @OperationLogIgnore
    @PostMapping("/governance/search_count")
    @ApiOperation(value = "查询后端服务实例统计信息")
    public Result<List<SearchServiceGovernanceCountResp>> searchServiceGovernanceCount() {
        return Result.getSuccessResult(dashboardService.searchServiceGovernanceCount());
    }

}
